Developer --> Technical Publications
PATHMac OS 8 Developer Documentation > Files > Navigation Services >

Programming With Navigation Services 1.1


Filtering File Objects

Navigation Services notifies you before displaying items in the following areas:

You can take advantage of this notification process by creating a filter function, described in this document as MyFilterProc , to determine which items are displayed. Register your filter function by passing a Universal Procedure Pointer (UPP) in the filterProc parameter of a Navigation Services function such as NavGetFile . You obtain this UPP by calling the macro NewNavObjectFilterProc and passing a pointer to your filter function. When calling your filter function, Navigation Services provides detailed information on HFS files and folders via a structure of type NavFileOrFolderInfo . Your filter function specifies which file objects to display to the user by returning true for each object you wish to display and false for each object you do not wish to display. If your filter function does not recognize an object, it should return true and allow the object to be displayed.

IMPORTANT

Your filter function must not assume that the data passed in theItem parameter is a 'typeFSS' Apple event descriptor. If you intend to use the data passed in the theItem parameter, you must first determine its Apple event descriptor type by attempting to coerce the data into a type that you expect or support. If the AEDesc structure cannot be coerced into a valid file specification, for example, the data passed in the info parameter does not refer to an HFS file object. For more information on working with AEDesc structures, see Inside Macintosh: Interapplication Communication.

Listing 7 illustrates a sample filter function that allows only text files to be displayed.

Listing 7 A sample filter function

pascal Boolean myFilterProc(AEDesc* theItem, void* info,
                            NavCallBackUserData callBackUD,
                            NavFilterModes filterMode)
{
    OSErr theErr = noErr;
    Boolean display = true;
    NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*)info;
    
    if (theItem->descriptorType == typeFSS)
        if (!theInfo->isFolder)
            if (theInfo->fileAndFolder.fileInfo.finderInfo.fdType
                != 'TEXT')
                display = false;
    return display;
}

IMPORTANT

Navigation Services expects your filter function to return true if an object is to be displayed. This is the opposite of what Standard File expects from file filter functions.

For more information on object filtering options, see Filtering File Objects.


© 1998 Apple Computer, Inc. – (Last Updated 23 Nov 98)

Previous | Back Up One Level | Next |





Find: 
Copyright © 1998 Apple Computer, Inc. All rights reserved.